package loops;

public class CollectionMoney {
	public static void main(String[] args) {
		// 有若干1，2，5，10元钱，问凑够20元，有多少中方法
		int count = 0;
		for (int coin1 = 0 ; coin1 <= 20; coin1++) {
			for (int coin2 = 0; coin2 <= 10 ; coin2++) {
				for (int coin5 = 0; coin5 <= 4; coin5++) {
					for (int coin10 = 0; coin10 <= 2; coin10++) {
						if (coin1 * 1 + coin2 * 2 + coin5 * 5 + coin10 * 10 == 20) {
							System.out.println("1元:" + coin1 + ",2元:" + coin2 + ",5元:" + coin5 + ",10元:" + coin10);
							count++;
						}
					}
				}
			}
		}
		System.out.println(count);
		
		// 100百文钱买100百鸡，公鸡5文一只，母鸡3文一只, 小鸡3只1文
		// TIP: 小鸡的数量一定是3个倍数，把满足条件的输出出来
		count = 0;
		for (int cock = 0; cock <= 20; cock++) {
			for (int hen = 0; hen <= 33; hen++) {
				for (int chicken = 0; chicken <= 100; chicken += 3) {
					if (cock * 5 + hen * 3 + chicken / 3 == 100 && cock + hen + chicken == 100) {
						count++;
						System.out.println("公鸡：" + cock + "   母鸡：" + hen + "   小鸡：" + chicken);
					}
				}
			}
		}
		System.out.println(count);
	}
}
